package com.kamistoat.reactortest.service.impl;

import com.kamistoat.reactortest.entity.Order;
import com.kamistoat.reactortest.service.OrderService;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class OrderServiceImpl implements OrderService {

    @Override
    public Flux<Order> getOrders() {
        // 假设这是使用 响应式CRUD查询出的订单表
        ArrayList<Order> orders = new ArrayList<>();
        Order order_1 = new Order();
        Order order_2 = new Order();
        order_1.setId(1L);
        order_1.setName("手机");
        order_2.setId(2L);
        order_2.setName("电脑");
        orders.add(order_1);
        orders.add(order_2);

        return Flux.fromIterable(orders);
    }

    @Override
    public Mono<Void> deleteOrderById(Long id) {
        return Mono.empty();
    }


    @Override
    public Mono<Order> getOrderById(Long id) {
        // 假设这是使用 响应式CRUD查询出的订单
        Order order = new Order();
        order.setId(id);
        order.setName("查询测试");

        return Mono.justOrEmpty(order);
    }
}
